$(document).ready(function(){
    var documentOffset = getDocumentOffset();
    var articleId = $("#articleId").val();

    $(window).bind("scroll",function()
    {
        documentOffset = getDocumentOffset();
        if(documentOffset > $("#loading").offset().top - 50)
        {
            loadComments(articleId);
            $(window).unbind("scroll");
            $("#loading").hide();
        }
    });

});